<?php
	if( ! isset($_SESSION['sftp']) )
		$_SESSION['sftp'] = array();

	$arr = explode("?", $_GET['msg']);
	foreach( $arr AS $line ) {
		$line = trim($line);
		if( $line != "" ) {
			$arr = explode('!', $line);
			if( $arr[0] == 'add' && ! in_array($arr[2], $_SESSION['sftp']) ) {
				$_SESSION['sftp'][] = $arr[2];
			}
			else if( $arr[0] == 'remove' && ($id = array_search($arr[2], $_SESSION['sftp'])) ) {
				unset($_SESSION['sftp'][ $id ]);
			}
		}
	}
	foreach( $_SESSION['sftp'] AS $line ) {
		echo $line."<br>";
	}
?>
